using System;

namespace Scenario.Modules.FormHelper
{
	//*********************************************************************
	//
	// Flag Class
	//
	// The XMLFlag class represents a particulare action to do on an activity
	// or on a process. Flag contains the ActionType to do and its value
	// 
	//*********************************************************************

	public class XMLFlag : bOSdotNET.XML.Data.XMLObject
	{
		public const string MAIN_NODE		= "Flag";

		public const string TYPE_ATTRIBUTE	= "Type";

		// General flags values
		public const string YES_VALUE		="YES";
		public const string NO_VALUE		="NO";

		// Parameters flags 
		public const string GET_VALUE		="GET";
		public const string SET_VALUE		="SET";

		// Get on activity or workitem flags
		public const string LIST_TYPE				="LIST";
		public const string LISTRUNNING_TYPE		="LISTRUNNING";
		public const string LISTNOTRUNNING_TYPE		="LISTNOTRUNNING";
		public const string LISTCOMPLETED_TYPE		="LISTCOMPLETED";
		public const string HISTORYLOG_TYPE			="HISTORYLOG";
		public const string LOG_TYPE				="LOG";


		// Do  on activity or workitem flags
		public const string COMPLETE_TYPE	="COMPLETE";
		public const string ASSIGN_TYPE		="ASSIGN";
		public const string ACQUIRE_TYPE	="ACQUIRE";
		public const string REASSIGN_TYPE	="REASSIGN";
		public const string DO_TYPE			="DO";
		public const string RELEASE_TYPE	="RELEASE";
		public const string STOP_TYPE		="STOP";


		
		/** FIELDS **/

		public string sType;
		public string sValue;

		/** CONSTRUCTORS **/

		/** CONSTRUCTOR Width simple Property **/
		public XMLFlag()
		{
			this.Init();
		}

		/** CONSTRUCTOR Width XML parsering**/
		public XMLFlag(System.Xml.XmlNode node)
		{
			this.Parse(node);
		}

		override public void Init()
		{
			sType= string.Empty;
			sValue= string.Empty;
		}

		/** PROPERTIES **/


		public string Type 
		{
			get { return sType; }
			set { sType = value; }
		}

		public string Value 
		{
			get { return sValue; }
			set { sValue = value; }
		}
		
		/** INSTANCE METHODS **/

		/** Parsering method for filling the flag **/
		override public void Parse(System.Xml.XmlNode node2Parse)
		{
			this.Init();

			System.Xml.XmlNode node;

			/** find the attributes situated on the root tag **/
			for ( int i=0; i<node2Parse.Attributes.Count;i++)
			{
				node = node2Parse.Attributes.Item(i);

				switch ( node.Name )
				{
					case XMLFlag.TYPE_ATTRIBUTE:
						sType = node.InnerText;
						break;
				}
			}

			sValue = node2Parse.InnerText;
			
		}

		override public bOSdotNET.XML.XMLNode GetXMLNode()
		{
			bOSdotNET.XML.XMLNode xmlNode = new bOSdotNET.XML.XMLNode(XMLFlag.MAIN_NODE,sValue);
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute ( XMLFlag.TYPE_ATTRIBUTE, sType) );
			
			return xmlNode;
		}

		/** STATIC METHODS **/

		/** no static methods **/
	}
}
